/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistence;

import core.AEntityContentProvider;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Set;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ivan
 */
@Entity
@Table(name = "RATING")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Rating.findAll", query = "SELECT r FROM Rating r"),
    @NamedQuery(name = "Rating.findByRatingId", query = "SELECT r FROM Rating r WHERE r.ratingId = :ratingId"),
    @NamedQuery(name = "Rating.findByVictory", query = "SELECT r FROM Rating r WHERE r.victory = :victory"),
    @NamedQuery(name = "Rating.findByLoseOut", query = "SELECT r FROM Rating r WHERE r.loseOut = :loseOut"),
    @NamedQuery(name = "Rating.findByDraw", query = "SELECT r FROM Rating r WHERE r.draw = :draw"),
    @NamedQuery(name = "Rating.findByAchievements", query = "SELECT r FROM Rating r WHERE r.achievements = :achievements"),
    @NamedQuery(name = "Rating.findByScore", query = "SELECT r FROM Rating r WHERE r.score = :score")})
public class Rating extends AEntityContentProvider<Rating> implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    //@Basic(optional = false)
    //@NotNull
    @GeneratedValue(generator="CommonSeq", strategy= GenerationType.SEQUENCE)
   // @SequenceGenerator( name="CommonSeq",sequenceName="common_seq", allocationSize=1)
    @Column(name = "RATING_ID")
    private BigDecimal ratingId;
    @Basic(optional = false)
    @NotNull
    @Column(name = "VICTORY")
    private BigInteger victory;
    @Basic(optional = false)
    @NotNull
    @Column(name = "LOSE_OUT")
    private BigInteger loseOut;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DRAW")
    private BigInteger draw;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "ACHIEVEMENTS")
    private String achievements;
    @Basic(optional = false)
    @NotNull
    @Column(name = "SCORE")
    private BigInteger score;
    @OneToMany(mappedBy = "ratingId")
    private Set<Player> playerSet;
    @OneToMany(mappedBy = "ratingId")
    private Set<Team> teamSet;

    public Rating() {
    }

    public Rating(BigDecimal ratingId) {
        super(Rating.class);
        this.ratingId = ratingId;
    }

    public Rating(BigDecimal ratingId, BigInteger victory, BigInteger loseOut, BigInteger draw, String achievements, BigInteger score) {
        super(Rating.class);
        this.ratingId = ratingId;
        this.victory = victory;
        this.loseOut = loseOut;
        this.draw = draw;
        this.achievements = achievements;
        this.score = score;
    }

    public BigDecimal getRatingId() {
        return ratingId;
    }

    public void setRatingId(BigDecimal ratingId) {
        this.ratingId = ratingId;
    }

    public BigInteger getVictory() {
        return victory;
    }

    public void setVictory(BigInteger victory) {
        this.victory = victory;
    }

    public BigInteger getLoseOut() {
        return loseOut;
    }

    public void setLoseOut(BigInteger loseOut) {
        this.loseOut = loseOut;
    }

    public BigInteger getDraw() {
        return draw;
    }

    public void setDraw(BigInteger draw) {
        this.draw = draw;
    }

    public String getAchievements() {
        return achievements;
    }

    public void setAchievements(String achievements) {
        this.achievements = achievements;
    }

    public BigInteger getScore() {
        return score;
    }

    public void setScore(BigInteger score) {
        this.score = score;
    }

    @XmlTransient
    public Set<Player> getPlayerSet() {
        return playerSet;
    }

    public void setPlayerSet(Set<Player> playerSet) {
        this.playerSet = playerSet;
    }

    @XmlTransient
    public Set<Team> getTeamSet() {
        return teamSet;
    }

    public void setTeamSet(Set<Team> teamSet) {
        this.teamSet = teamSet;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ratingId != null ? ratingId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Rating)) {
            return false;
        }
        Rating other = (Rating) object;
        if ((this.ratingId == null && other.ratingId != null) || (this.ratingId != null && !this.ratingId.equals(other.ratingId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "persistence.Rating[ ratingId=" + ratingId + " ]";
    }
    
}
